CISC 1110                     Lab 20

 

Write a C++ program which works with strings, using two functions. One function will show how a function can return a string. The other function will show how a function can modify a reference parameter which is a string.  

 

You will write a main program which calls two functions: cutfront and changeme.

 

A. In the main program, declare several strings and assign them values.  

 

     Then have the main program call cutfront, sending it one of the strings. After returning from the function, main will store the returned answer in a second string. After the call, main should print the second string.

 

       Then have the main program call changeme, sending it two strings.  After the call, main should print both of the strings. Only one of the strings will be changed by the function.

 

B.  Write the prototypes:

   The prototype for cutfront shows that the function has one string parameter and that the function returns a string.

 

   The prototype for changeme shows that this is a void function that has two parameters, one of which is a string, and one of which is a reference to a string.

 

C.  Write the functions:

    In cutfront, declare a local variable which is a string. Give it a value equal to the first 4 letters of the parameter string. Return this variable.

 

     In changeme, erase any 3 letters from the middle of each string. Print both strings in the function. 

 

     Run the whole program.